<%-- 
    Document   : index
    Created on : Mar 16, 2011, 4:07:29 PM
    Author     : ChuckToh
--%>

<%@page import="javax.script.ScriptEngine"%>
<%@page import="javax.script.ScriptEngineManager"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
    "http://www.w3.org/TR/html4/loose.dtd">

<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>E-Oasis Learning Portal! - The best you can get.</title>
    </head>
    <body>
    <link type="text/css" href="../Scripts/css/smoothness/jquery-ui-1.8.11.custom.css" rel="stylesheet"/>
    <script type="text/javascript" src="../Scripts/js/jquery-1.4.4.min.js"></script>
    <script type="text/javascript" src="../Scripts/js/jquery-ui-1.8.11.custom.min.js"></script>
    <script type="text/javascript">
        $(function(){
            //tabs
            $('#tabs').tabs();

            //date picker
            $('#datepicker').datepicker({inline: true});
            $('#datepicker').datepicker("option","dateFormat",'yy-mm-dd');

            $('#datepicker2').datepicker({inline: true});
            $('#datepicker2').datepicker("option","dateFormat",'yy-mm-dd');
        })

        function loadXMLDoc(url,div)
        {
            var xmlhttp;
            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp=new XMLHttpRequest();
            }
            else
            {// code for IE6, IE5
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange=function()
            {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                    document.getElementById(div).innerHTML=xmlhttp.responseText;
                } else {
                    document.getElementById(div).innerHTML="<img src='ajax-loader.gif'>";
                }
            }
            xmlhttp.open("POST",url,true);
            xmlhttp.send();
        }

        function loadCategorySideBar(category)
        {
            var url = "viewDocumentParts/categoriesSideBar.jsp?category="+category;
            var xmlhttp;
            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp=new XMLHttpRequest();
            }
            else
            {// code for IE6, IE5
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange=function()
            {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                    document.getElementById("categorySideBar").innerHTML=xmlhttp.responseText;
                } else {
                    document.getElementById("categorySideBar").innerHTML="<img src='ajax-loader.gif'>";
                }
            }
            xmlhttp.open("POST",url,true);
            xmlhttp.send();
        }

        function loadContent(id)
        {
            var url = "viewDocumentParts/content.jsp?id="+id;
            var xmlhttp;
            if (window.XMLHttpRequest)
            {// code for IE7+, Firefox, Chrome, Opera, Safari
                xmlhttp=new XMLHttpRequest();
            }
            else
            {// code for IE6, IE5
                xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
            }
            xmlhttp.onreadystatechange=function()
            {
                if (xmlhttp.readyState==4 && xmlhttp.status==200)
                {
                    document.getElementById("content").innerHTML=xmlhttp.responseText;
                } else {
                    document.getElementById("content").innerHTML="<img src='ajax-loader.gif'>";
                }
            }
            xmlhttp.open("POST",url,true);
            xmlhttp.send();
        }
    </script>
    <%
                if (session.getAttribute("afterVoteMessage") != null) {
                    out.println("<script>loadXMLDoc('Nicholasvote.jsp','tabs-2');</script>");
                } else if (session.getAttribute("afterNewDocumentMessage") != null) {
                    out.println("<script>loadXMLDoc('NicholascreateDocument.jsp','tabs-7');</script>");
                } else {
                    out.println("<script>loadXMLDoc('NicholassendFeedback.jsp','tabs-1');</script>");
                }
    %>

    <div id="tabs">
        <ul>
            <li><a href="#tabs-1" onclick="loadXMLDoc('NicholassendFeedback.jsp','tabs-1')">Send Feedback</a></li>
            <li><a href="#tabs-2" onclick="loadXMLDoc('Nicholasvote.jsp','tabs-2')">Vote</a></li>
            <li><a href="#tabs-3">Create voting list</a></li>
            <li><a href="#tabs-4" onclick="loadXMLDoc('NicholasviewFeedbacks.jsp','tabs-4')">View feedbacks</a></li>
            <li><a href="#tabs-5" onclick="loadXMLDoc('NicholasviewVotingList.jsp','tabs-5')">View voting list</a></li>
            <li><a href="#tabs-6" onclick="loadXMLDoc('NicholasviewVotes.jsp','tabs-6')">View votes</a></li>
            <li><a href="#tabs-7" onclick="loadXMLDoc('NicholascreateDocument.jsp','tabs-7')">Create new document</a></li>
            <li><a href="#tabs-8" onclick="loadXMLDoc('NicholasviewDocument.jsp','tabs-8')">View document</a></li>
        </ul>
        <div id="tabs-1"></div>
        <div id="tabs-2"></div>
        <div id="tabs-3">
            <jsp:include flush="true" page="NicholascreateNewVotingList.jsp"></jsp:include>
        </div>
        <div id="tabs-4"></div>
        <div id="tabs-5"></div>
        <div id="tabs-6"></div>
        <div id="tabs-7"></div>
        <div id="tabs-8"></div>
    </div>
</body>
</html>
